<?php

namespace app\netdisk\middleware;

use app\Request;

use think\facade\Log;
use think\facade\Cache;

class AuthTokenMiddleware
{
    /**
     * Request实例
     * @var \think\Request
     */
    protected $request;

    /**
     * 权限规则验证
     * Class AdminCkeckRole
     * @package appx\middleware
     */
    public function handle(Request $request, \Closure $next)
    {
        $token = $request->header('auth-token');
        $userInfo = Cache::get($token);
        if ($userInfo) {
            $request->userInfo = $userInfo;
            return $next($request);
        }

        return json(['status' => 400, 'msg' => "用户未登录"]);
    }
}
